using System;
using System.Runtime.Serialization;

namespace Pegasus.UnitTests.Runtime.Serialization.Formatters.Xml.XmlFormatter2Tests
{
	/// <summary>
	/// Used with the Singleton class to test the object reference serialization functionality
	/// </summary>
	[Serializable]
	public class SingletonObjectRef : IObjectReference, ISerializable, IDeserializationCallback
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="T:SingletonObjectRef"/> class.
		/// </summary>
		public SingletonObjectRef()
		{
			object a = 0;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="T:SingletonObjectRef"/> class.
		/// </summary>
		/// <param name="info">The info.</param>
		/// <param name="context">The context.</param>
		protected SingletonObjectRef( SerializationInfo info, StreamingContext context )
		{
			object a = 0;
		}

		/// <summary>
		/// Returns the real object that should be deserialized, rather than the object that the serialized stream specifies.
		/// </summary>
		/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"></see> from which the current object is deserialized.</param>
		/// <returns>
		/// Returns the actual object that is put into the graph.
		/// </returns>
		/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
		public object GetRealObject( StreamingContext context )
		{
			return Singleton.GetInstance();
		}

		/// <summary>
		/// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> with the data needed to serialize the target object.
		/// </summary>
		/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> to populate with data.</param>
		/// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) for this serialization.</param>
		/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
		public void GetObjectData( SerializationInfo info, StreamingContext context )
		{
			object a = 0;
		}


		/// <summary>
		/// Runs when the entire object graph has been deserialized.
		/// </summary>
		/// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
		public void OnDeserialization( object sender )
		{
			object a = 0;
		}
	}
}
